package com.leet.code.simple_array;

/**
 * @description:
 * @author: WYG
 * @time: 2020/12/31 10:59
 */

public class DecompressRLElist {
    /**
     *
     * @param nums
     * @return
     */
    public int[] decompressRLElist(int[] nums) {
        int size = 0;
        for (int i = 0; i < nums.length; i=i+2) {
            size += nums[i];
        }
        int[] res = new int[size];
        int k = 0;
        for (int i = 0; i < nums.length; i=i+2) {
            for (int j = 0; j < nums[i]; j++) {
                res[k] = nums[i + 1];
                k++;
            }
        }
        return res;
    }
}
